package tx.plus;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

import javax.sql.DataSource;

public class TxPlusAutoConfiguration implements BeanPostProcessor {

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

        if (!(bean instanceof DataSource)) {
            return bean;
        }
        if (bean instanceof PlusDataSource) {
            return bean;
        }
        return new PlusDataSource((DataSource) bean);
    }
}
